using System;
using System.Collections;

namespace TimeSheetBLL
{
    /// <summary>
    /// Summary description for UserProjects.
    /// </summary>
    public class UserProjects
    {
        private User user;
        private Hashtable projectHoursCollection;

        public UserProjects(long userID)
        {
            user.ID = userID;
            projectHoursCollection = new Hashtable();
        }

        public void AddProjectHours(ProjectHours ph)
        {
            ProjectHours proj = projectHoursCollection[ph.ProjectID] as ProjectHours;
            if (proj == null)
            {
                projectHoursCollection.Add(ph.ProjectID, proj);
            }
            else
            {
                foreach (string date in ph.HoursWorkedCollection.Keys)
                {
                    double hours = (double) ph.HoursWorkedCollection[date];
                    proj.AddHours(Convert.ToDateTime(date), hours);
                }
            }
        }

        public Hashtable ProjectHoursCollection
        {
            get { return projectHoursCollection; }
            set { projectHoursCollection = value; }
        }

        private User LoadUser()
        {
            BrokerFactory.Fill(user);
            return user;
        }
    } //class
} //namespace